
;=================================================
; `is` relations database
;
(defparameter *is-rel-db* (make-hash-table))

(defun is (lhs rhs)
 (equal (gethash lhs *is-rel-db*) rhs)
 )

(defun insert-relation (relation)
 (cond
  ((eq 'is (first relation))
                (setf (gethash (second relation) *is-rel-db*) (third relation)))
  (t (error "relation is undefined"))
  )
 )

(defun def-proc-rule (&key (name nil) context action)
 (declare (string name) (list context) (list action))
 (dump "dfr ~a ~a ~a~%" name context action)
)

(defun test-defrel ()
 (dump "in test defrel\n")
 (insert-relation '(is vector object))
 (if (is 'vector 'object)
  (dump "vector is object")
  )
 ;(def-proc-rule :name 45 :context '(1 2) :action 45)
)

;=================================================
; if entity is disposable it is required to dispose
; its data after having entity used

(defun rels (&rest args)
 (dolist (arg args)
  (dump "rel = ~a" arg)
  )
 )

(defun procs (&rest args)
 (dolist (arg args)
  (dump "prc = ~a" arg)
  ))


(defun test-lime ()
 (dump "test-lime")

 (test-defrel)
 (return-from test-lime)

 (rels
  ; Vector is Disposable-Object  what means that it requires
  ; destructive operation after being used
  '(is vector disposable-object)

  ; Vector have
  ; Vector::Length
  ; Vector::Allocated
  ; Vector::Buffer
  '(have vector (and length allocated buffer))

  ; Vector::Length specification
  '(is (from length vector) (and attribute read-only unsigned))
  )

 (dump "===================")

 (procs

  ; set all the members of vector to zero
  '(
      ; condition
      (is vector created)
      ; actions
      (set (from (and length allocated buffer) vector) 0)
  )

  ; add one element
  '(
      (add-to element vector)
   )
  )
 )

